//
// Created by wze-zero on 2024/7/21 021.
//
#include <iostream>

using namespace std;

class BaseCalculator {
public:
    int m_A;
    int m_B;

    BaseCalculator() {

    }

    virtual int getResult() = 0;

    virtual ~BaseCalculator() {

    }
};


// 加法计算器类
class AddCalculator : public BaseCalculator {
    int getResult() override {
        return this->m_A + this->m_B;
    }
};

// 减法计算器类
class SubCalculator : public BaseCalculator {
    int getResult() override {
        return this->m_A - this->m_B;
    }

};


int main() {
    BaseCalculator *cal = new AddCalculator;
    cal->m_A = 10;
    cal->m_B = 20;
    cout << cal->getResult() << endl;
    delete cal;
    cal = new SubCalculator;
    cal->m_A = 20;
    cal->m_B = 10;
    cout << cal->getResult() << endl;
    delete cal;
    return 0;
}